extends MoveElement


class_name GravityElement
"""
重力效果
"""


## 重力方向
@export var velocity: Vector2 = Vector2.ZERO:
    set(v):
        velocity = v
        is_enable = not velocity.is_zero_approx()

## 衰减系数
@export_range(0, 1.0) var lerp_weight: float = 0


func yield_move(delta: float) -> Vector2:
    if not velocity.is_zero_approx():
        velocity = velocity.lerp(Vector2.ZERO, lerp_weight)
    else:
        is_enable = false
    return velocity
